load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load(
    ":REPOSITORIES.bzl",
    "CONFIG_DARWIN_AMD64",
    "CONFIG_DARWIN_ARM64",
    "CONFIG_LINUX_AMD64",
    "CONFIG_LINUX_ARM64",
    "target",
)

filegroup(
    name = "testdata",
    srcs = glob(
        ["testdata/**"],
        exclude = [
            "**/*~",
            "**/#*#",
            "**/.*.swp",
            "**/.#*",
        ],
    ),
    visibility = [
        "//pkg/ccl/logictestccl:__subpackages__",
        "//pkg/cmd/generate-logictest:__pkg__",
        "//pkg/sql/logictest:__subpackages__",
        "//pkg/sql/schemachanger:__pkg__",
    ],
)

filegroup(
    name = "cockroach_predecessor_version",
    srcs = select({
        "//build/toolchains:is_linux_amd64": target(CONFIG_LINUX_AMD64),
        "//build/toolchains:is_linux_arm64": target(CONFIG_LINUX_ARM64),
        "//build/toolchains:is_darwin_amd64": target(CONFIG_DARWIN_AMD64),
        "//build/toolchains:is_darwin_arm64": target(CONFIG_DARWIN_ARM64),
        "//conditions:default": [],
    }),
    visibility = [
        "//pkg/ccl/logictestccl/tests/cockroach-go-testserver-24.1:__pkg__",
        "//pkg/ccl/logictestccl/tests/cockroach-go-testserver-24.2:__pkg__",
        "//pkg/sql/logictest/tests/cockroach-go-testserver-24.1:__pkg__",
        "//pkg/sql/logictest/tests/cockroach-go-testserver-24.2:__pkg__",
    ],
)

go_library(
    name = "logictest",
    testonly = 1,
    srcs = ["logic.go"],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/logictest",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/build/bazel",
        "//pkg/cloud/externalconn/providers",
        "//pkg/clusterversion",
        "//pkg/col/coldata",
        "//pkg/kv/kvclient/rangefeed",
        "//pkg/kv/kvserver",
        "//pkg/kv/kvserver/kvserverbase",
        "//pkg/multitenant/tenantcapabilities",
        "//pkg/security/username",
        "//pkg/server",
        "//pkg/settings/cluster",
        "//pkg/sql",
        "//pkg/sql/execinfra",
        "//pkg/sql/logictest/logictestbase",
        "//pkg/sql/parser",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/randgen",
        "//pkg/sql/rowinfra",
        "//pkg/sql/schemachanger/corpus",
        "//pkg/sql/schemachanger/scexec",
        "//pkg/sql/sem/eval",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondatapb",
        "//pkg/sql/sqlstats",
        "//pkg/sql/stats",
        "//pkg/testutils",
        "//pkg/testutils/datapathutils",
        "//pkg/testutils/floatcmp",
        "//pkg/testutils/physicalplanutils",
        "//pkg/testutils/release",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/skip",
        "//pkg/testutils/sqlutils",
        "//pkg/util/envutil",
        "//pkg/util/log",
        "//pkg/util/metamorphic",
        "//pkg/util/randutil",
        "//pkg/util/timeutil",
        "//pkg/util/tracing",
        "@com_github_cockroachdb_cockroach_go_v2//testserver",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_kr_pretty//:pretty",
        "@com_github_lib_pq//:pq",
        "@com_github_pmezard_go_difflib//difflib",
        "@com_github_stretchr_testify//require",
    ],
)

go_test(
    name = "logictest_test",
    size = "medium",
    srcs = [
        "main_test.go",
        "parallel_test.go",
    ],
    data = [":testdata"],
    embed = [":logictest"],
    exec_properties = {"test.Pool": "large"},
    deps = [
        "//pkg/base",
        "//pkg/config/zonepb",
        "//pkg/keys",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/security/username",
        "//pkg/server",
        "//pkg/sql",
        "//pkg/sql/logictest/logictestbase",
        "//pkg/sql/sessiondatapb",
        "//pkg/sql/stats",
        "//pkg/sql/tests",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/skip",
        "//pkg/testutils/sqlutils",
        "//pkg/testutils/testcluster",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/protoutil",
        "//pkg/util/randutil",
        "@com_github_gogo_protobuf//proto",
        "@in_gopkg_yaml_v2//:yaml_v2",
    ],
)
